/*
 * @Author: wz
 * @Date: 2020-11-27 15:04:17
 * @LastEditors: wz
 * @LastEditTime: 2020-12-07 14:57:14
 * @Description: 对返回数据函数处理
 */

// 对象遍历，并返回一个数组
export const mapsWalk = (maps, handler) => {
    var key
    var res
    var arr = []
    for (key in maps) {
        res = handler(key, maps[key], maps)
        if (res !== undefined) {
            arr.push(res)
        }
    }
    return arr
}
// 查询条件格式化
export const conditionsFormator = (querys, filters) => {
    filters = filters || {}
    return mapsWalk(querys, function (key, val) {
        if (val === '' || val === null || val === undefined) return
        var res = {}
        res.attributeName = key
        res.rangeType = filters[key] ? filters[key] : 'EQUAL'
        res.targetValue = Array.isArray(val) ? val : [val]
        return res
    })
}
